#ifndef AURORA_MUSIC_H
#define AURORA_MUSIC_H

#include <QWidget>
#include "volumetool.h"
#include "musiclist.h"
#include <QMediaPlayer>
#include <QMediaPlaylist>
#include <QSqlDatabase>
#include <QPropertyAnimation>
#include "commonpage.h"
#include "lrcpage.h"

QT_BEGIN_NAMESPACE
namespace Ui { class aurora_music; }
QT_END_NAMESPACE

class aurora_music : public QWidget
{
    Q_OBJECT

public:
    aurora_music(QWidget *parent = nullptr);
    ~aurora_music();
    void initUI();
    QJsonArray RandomPicture();
    void onUpdateLikeMusic(bool isLike, QString musicId);
    void initPlayer();
    void setPlayerVolume(int vomume);
    void onMusicSliderChanged(float value);
    void onMetaDataAvailableChangedChanged(bool available);
    void initSQLite();
    void initMusicList();
    void onLrcWordClicked();
    void quitQQMusic();

protected:
    void mousePressEvent(QMouseEvent *event)override;
    void mouseMoveEvent(QMouseEvent* event)override;

private slots:
    void on_quit_clicked();
    void connectSignalAndSlot();
    void onBtFormClick(int id);

    void on_volume_clicked();

    void on_addLocal_clicked();
    void onPlayCliked();
    void onPlayStateChanged();
    void onPlayUpCliked(); // 上⼀曲
    void onPlayDownCliked(); // 下⼀曲
    void onPlaybackModeCliked();
    void onPlaybackModeChanged(QMediaPlaylist::PlaybackMode playbackMode);
    void onPlayAll(PageType pageType);
    void playAllOfCommonPage(CommonPage* commonPage, int index);
    void playMusicByIndex(CommonPage* page, int index);
    void onCurrentIndexChanged(int index);
    void setMusicSilence(bool isMuted);
    void onDurationChanged(qint64 duration);
    void onPositionChanged(qint64 duration);

    void on_skin_clicked();

    void on_min_clicked();

private:
    Ui::aurora_music *ui;
    QPoint dragPosition;
    VolumeTool* volumeTool;
    MusicList musicList;
    QMediaPlayer* player;
    QMediaPlaylist* playerList;
    CommonPage* currentPage;
    qint64 totalTime;
    int currentIndex;
    QSqlDatabase sqlite;
    LrcPage* lrcPage;
    QPropertyAnimation* lrcAnimation;
    bool isDrag;
};
#endif // AURORA_MUSIC_H
